<?php 
	session_start();
	$var1= $_SESSION["registrado"];
	$var2= $_SESSION["administrador"];
	if ($var1 == null): {
		echo ("User not registered");
	} elseif ($var2 == 0): { 
			echo ("User without permissions");
	} else : {
?>

<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/bootstrap-responsive.css" rel="stylesheet"	media="screen">

<title>My project manager</title>

</head>

<body>
<?php include ('configuration.php'); ?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap.js"></script>


<div class="navbar navbar-inverse navbar-fixed-top">
	<div class="navbar-inner">
		<div class="container-fluid">
			<button type="button" class="btn btn-navbar" data-toggle="collapse"
				data-target=".nav-collapse">
				<span class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
			<a class="brand" href="http://localhost/bases--grupo10/homeAdmin.php?">My project manager</a>
			<div class="nav-collapse collapse">
				<p class="navbar-text pull-right">
				
					<a href="http://localhost/bases--grupo10/logout.php?" class="navbar-link">Log out</a>
				</p>
				<ul class="nav">
					<li class="active"><a href="http://localhost/bases--grupo10/homeAdmin.php?">Home</a></li>
					<li><a href="http://localhost/bases--grupo10/about.php?">About</a></li>
					<li><a href="http://localhost/bases--grupo10/contact.php?">Contact</a></li>
				</ul>
			</div>
		</div>
	</div>
</div>

<div class="container-fluid">
	<div class="row-fluid">
		<div class="span2">
		<div class="well sidebar-nav">
			<ul class="nav nav-list">
				
				<li class="nav-header">MEMBERS</li>
				<li><a href="http://localhost/bases--grupo10/newMember.php?">New member</a></li>
				<li><a href="http://localhost/bases--grupo10/modifyMember.php?">Modify member</a></li>
				<li><a href="http://localhost/bases--grupo10/deleteMember.php?">Delete member</a></li>
				<li class="nav-header">PROJECTS</li>
				<li><a href="http://localhost/bases--grupo10/newProject.php?">New project</a></li>
				<li><a href="http://localhost/bases--grupo10/modifyProject.php?">Modify project</a></li>
				<li><a href="http://localhost/bases--grupo10/deleteProject.php?">Delete project</a></li>
				<li class="nav-header">OTHER OPTIONS</li>
				<li><a href="http://localhost/bases--grupo10/administrators.php?">Administrators</a></li>
				<li><a href="http://localhost/bases--grupo10/graphs.php?">Graphs</a></li>
				<li><a href="http://localhost/bases--grupo10/compare.php?">Compare versions</a></li>
			</ul>
		</div>
		</div>
		<div class="span10">
			<div class="hero-unit">
			<?php
			$var3= $_SESSION["variable"];?>
			<h1>Hello <?php echo $var3?>!</h1>
			<p>Administrator profile</p>
			</div>
		</div>
        <div class="span10">		
        <table class="table table-striped">  
            <thead>  
              <tr>  
                <th>Project Name</th>  
                <th><a class="btn btn-primary" type="button" href="http://localhost/bases--grupo10/order_projects.php?opcion=1&&asc=1">Version</a></th>  
                <th><a class="btn btn-primary" type="button" href="http://localhost/bases--grupo10/order_projects.php?opcion=2&&asc=1">Initial date</a></th>  
                <th><a class="btn btn-primary" type="button" href="http://localhost/bases--grupo10/order_projects.php?opcion=3&&asc=1">Final date</a></th> 
                <th><a class="btn btn-primary" type="button" href="http://localhost/bases--grupo10/order_projects.php?opcion=4&&asc=1">Advance</a></th>
                <th>Show</th>
                <th>Versions</th> 
              </tr>  
            </thead>  
            <tbody id="projects">  
          
        	<?php                 
             $q1 = mysql_query("select p.id_project, p.name_project, p.id_version, p.advantage, p.initial_date, p.final_date
                                from project p where p.id_version=(select max(P2.id_version)
                                      from Project P2
                                      where P.id_project=P2.id_project and P.deleted=0)") or die ("Query error");
             while($row=mysql_fetch_array($q1)){
                echo "<tr>";
                echo "<td>" . $row["name_project"] . "</td>";
                echo "<td>" . $row["id_version"] . "</td>";
                echo "<td>" . $row["initial_date"] . "</td>";
                echo "<td>" . $row["final_date"] . "</td>";
                echo "<td>" . $row["advantage"] . "</td>";?>
                <td><p><a class="btn" href="http://localhost/bases--grupo10/showProject.php?id_pro=<?php echo $row["id_project"] ?>">Show members &raquo;</a></p></td>
                <td><p><a class="btn" href="http://localhost/bases--grupo10/showVersions.php?id_pro=<?php echo $row["id_project"] ?>">Show versions &raquo;</a></p></td>
                <?php 
                echo "</tr>";
             }         
             ?>
            </tbody>  
        </table> 
    </div> 
</div> 
</div>   
</body>  
</html>  

<?php }endif;?>